package com.itcast.demo;

import com.itcast.SessionUtils.SessionUtils;
import com.itcast.domain.User;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.util.List;

public class Demo02 {
    public static void main(String[] args) throws Exception {
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(Resources.getResourceAsStream("sql.xml"));
        SqlSession session = factory.openSession();

        List<User> list = session.selectList("com.itheima.mapper.UserMapperTwo.findAll");
        System.out.println(list);
        /*User user=session.selectOne("com.itheima.mapper.UserMapper.findById",19);
        System.out.println(user);*/
        session.close();
    }






  /*  @Test
    public void findAll(){
        List<Object> objects = SessionUtils.getSession().selectList("com.itcast.mapper.UserMapperTwo.findAll");
        System.out.println("objects = " + objects);
        SessionUtils.getSession().close();


    }*/
}
